## Input for RCA is FPKM values calculated by Cuffnorm. Naming of the column should be according to software requirement (to be able to introduce colour of interest to groups of cells).
## Different FPKM tables can be merged. Ensure that Row Names (Gene Names) are identical in terms of order in both the tables. 

library(WGCNA)
ALLOW_WGCNA_THREADS=8
library(flashClust)
library(gplots)
library(preprocessCore)
library(RCA)
options(stringsAsFactors = FALSE)
data_cellline = read.table("FPKM.csv", sep="\t", header=TRUE, row.names=1)
fpkm_data = data_cellline;
color_to_use0 = colnames(fpkm_data);
color_to_use0 <- strsplit(color_to_use0,"__");
color_to_use <- paste("",lapply(color_to_use0,"[[",2),sep="");
color_to_use=gsub("\\.","#",color_to_use);
data_obj = dataConstruct(fpkm_data);
### filt out lowly expressed genes
data_obj = geneFilt(obj_in = data_obj);
### normalize gene expression data (Note: default is no normalization).
data_obj = cellNormalize(data_obj);
### log transform the data
data_obj = dataTransform(data_obj,"log10");
### project the expression data into Reference Component space
data_obj = featureConstruct(data_obj,method = "GlobalPanel");
### generate cell clusters
data_obj = cellClust(data_obj);
RCAPlot(data_obj,cluster_color_labels = color_to_use);
q()
